1. Field of The Invention
The present invention relates generally to a computer system for performing graphics operations and, more particularly, to a computer graphics and animation system that includes a lighting subsystem for performing lighting.
2. Related Art
Computer graphics systems are commonly used for displaying two- and three-dimensional graphical representations of objects on a two-dimensional video display screen. Current computer graphics systems provide highly detailed representations and are used in a variety of applications.
In a typical computer graphics system, an object or model to be represented on the display screen is broken down into multiple graphics primitives. Primitives are basic components of a graphics display and may include, for example, points, lines, vectors, and polygons such as triangles and quadrilaterals. Typically, a hardware/software scheme is implemented to render, or draw, the graphics primitives that represent a view of one or more objects being represented on the display screen.
Generally, the primitives of a three-dimensional object to be rendered are defined by a host computer in terms of primitive data. For example, when the primitive is a triangle, the host computer may define the primitives in terms of the coordinates (X, Y, Z, and W) of its vertices, as well as the red, green and blue and alpha (R, G, B and .alpha.) color values of each vertex. Additional primitive data may be used in specific applications. Rendering hardware interpolates the primitive data to compute the display screen pixels that represent each primitive, and the R, G, and B color values for each pixel.
The basic components of a computer graphics system typically include a graphics interface and some specialized graphics system hardware. The graphics interface is provided generally to enable graphics applications located on the host computer to control efficiently the graphics system hardware. One of the more popular graphics interfaces is the OpenGL.RTM. standard, which provides an application program interface (API) to the graphics system hardware. (OpenGL is a registered trademark of Silicon Graphics, Inc.).
The OpenGL software interface provides specific commands that are used to specify objects and operations to produce interactive, three-dimensional applications. OpenGL is a streamlined, hardware-independent interface designed to be implemented on many different hardware platforms. As such, in computer systems that support OpenGL, the operating systems and graphics application software programs can make calls to the computer graphics system according to the standardized API without knowledge of the underlying hardware configuration.
The OpenGL standard provides a complete library of low-level graphics manipulation commands for describing models of three-dimensional objects (the "GL" of OpenGL refers to "Graphics Library"). This standard was originally based on the proprietary standards of Silicon Graphics, Inc., but was later transformed into an open standard that is used in high-end graphics-intensive workstations, and, more recently, in high-end personal computers. The OpenGL standard is described in the OPENGL PROGRAMMING GUIDE, version 1.1 (1997), the OPENGL REFERENCE MANUAL, version 1.1 (1997), and a book by Segal and Akeley (of Silicon Graphics, Inc.) entitled THE OPENGL GRAPHICS SYSTEM: A SPECIFICATION, version 1.1 (1995), all of which are hereby incorporated by reference in their entirety.
The graphics system hardware typically includes a geometry accelerator, a rasterizer, and a frame buffer. The graphics system may also include other hardware such as texture mapping hardware. The geometry accelerator receives primitive data from the host computer via the graphics interface. The primitive data defines the primitives that make up a view of the model to be displayed. The geometry accelerator performs transformations on the primitive data and may also perform such functions as lighting and view and model clipping for each primitive. The output of the geometry accelerator, referred to as rendering data, is used by the rasterizer and the texture mapping hardware to generate final screen coordinate and color data for each pixel in each primitive. The pixel data from the rasterizer and the pixel data from the texture mapping hardware, if available, are combined and stored in the frame buffer for display on the video display screen.
In the OpenGL lighting model, one or more light sources can be individually controlled. OpenGL typically allows 8 or more light sources to be defined for any particular scene. Many parameters can be defined for each of these light sources. For example, it is possible to define the position, focus, direction, attenuation and color of each light source. OpenGL uses the defined light source information to perform lighting of geometric primitives to produce optical effects on the scene.
OpenGL specifies that light sources are to be defined in object coordinates. The term "object coordinates" is used generally to refer to a coordinate system associated with the physical item to be modeled. OpenGL further specifies that the defined light source information is to be transformed from object coordinates to eye coordinates and stored in eye coordinates. The term "eye coordinates" is used generally to refer to a coordinate system associated with the way in which the object or model is viewed in the particular scene. Coordinates, coordinate space and space will be used interchangeably herein.
An illustration may be helpful to understand the difference between eye coordinates and object coordinates. For example, think of a book sitting on a desk. The eye coordinate system would be affixed to the desk with, for example, the X coordinate extending along the front of the desk, the Y coordinate extending along the left side of the desk and the Z coordinate extending perpendicularly above the surface of the desk. The object coordinate system would be affixed to the book itself in a convenient manner, for example so as to define X', Y' and Z' coordinate axes as extending along the edges of the book. Using a coordinate system fixed to the book is simply a matter of convenience that simplifies specification of the object being defined. In this example, since the object coordinate system is attached to the edges of the book, it is easy to define the book as extending, for example, two units along the X' direction, three units along the Y' direction and 1 unit along the Z' direction. After the object has been defined in object coordinates, the object coordinate data can be easily translated into eye coordinates simply by multiplying the object coordinate data by a transformation matrix. In OpenGL, a 4.times.4 matrix referred to as the "model view matrix" (M) is used to transform data from object coordinates to eye coordinates.
As noted above, OpenGL specifies that light sources are defined in object coordinates and that the light source information is to be transformed into eye coordinates and stored in eye coordinates. The stored light source information is used, in connection with vertex and normal data, to perform lighting. Both the light source information and the vertex and normal data must be in the same coordinate systems to perform lighting.
The light source information stored in eye coordinates may be used directly to perform lighting in eye coordinates or may be re-transformed from eye coordinates to object coordinates to perform lighting in object coordinates. Using the light source information to perform lighting in eye coordinates will be referred to herein as "eye coordinate lighting" whereas using the light source information to perform lighting in object coordinates will be referred to herein as "object coordinate lighting."
Since the light source information is stored in eye coordinates while vertex and normal data is provided in object coordinates, eye coordinate lighting requires that the normals and vertices of all primitives be translated from object coordinates to eye coordinates. Such a transformation is resource intensive and can form a processing bottleneck in the operation of the computer graphics system.
Object coordinate lighting is advantageous in that it enables lighting to be performed without transforming normal and vertex data from object coordinates to eye coordinates. Performing lighting in object coordinates, however, is not without price. As noted, to perform object coordinate lighting, it is necessary to re-transform the light source information from eye coordinates to object coordinates. Further, since the re-transformed light source information represented in object coordinates is a function of the model view matrix (M), this re-transformation of light source information must take place any time the model view matrix (M) changes. This re-transformation of light source information is also resource intensive and can itself form a processing bottleneck in the computer graphics system.
Accordingly, there is a need for an efficient technique to perform lighting in a computer graphics system. Further, there is a need for a geometry accelerator or graphics pipeline that can perform lighting efficiently for use in a computer graphics system.